<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <p>姓名：{{ fullName }}</p>
      <div>姓：<input type="text" v-model="lastName" /></div>
      <div>名：<input type="text" v-model="firstName" /></div>
      <div>姓名：<input type="text" v-model="fullName" /></div>
    </div>

    <script src="../vue.js"></script>
    <script>
      var app = new Vue({
        el: '#app',
        data: {
          firstName: '三',
          lastName: '张',
        },
        computed: {
          fullName: {
            get() {
              return this.lastName + ' ' + this.firstName;
            },
            set(value) {
              console.log(value, 'hehe');
              const [lastName, ...firstName] = value;
              this.lastName = lastName || '';
              this.firstName = (firstName || '').join('').trim();
            },
          },
          // fullName() {
          //   return this.lastName + ' ' + this.firstName;
          // },
        },
      });
    </script>
  </body>
</html>
